Skip to content

[SVLS-9883] feat: let agents lock targets in DD_LOG_LEVEL_BY_TARGET - #183

Open
lym953 wants to merge 1 commit into
mainfrom
yiming.luo/serverless-logging-locked-targets
Open

lym953 wants to merge 1 commit into
mainfrom
yiming.luo/serverless-logging-locked-targets

Conversation

@lym953

@lym953 lym953 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem

In the Lambda extension, the new variable DD_LOG_LEVEL_BY_TARGET from DataDog/datadog-lambda-extension#1413 can turn on the logs of the HTTP libraries h2, hyper, reqwest and rustls. The extension sends its own logs to Datadog, and these libraries log each HTTP request, including the requests that send logs. So with hyper=debug, each flush adds lines to the next flush, and the customer pays for them. A review comment on #1413 asks to keep these four libraries off.

This PR

With this PR, an agent can lock some targets, so that DD_LOG_LEVEL_BY_TARGET cannot change their log level. The agent warns about an entry for a locked target and ignores it, as it does for a typo. For example, if the agent locks h2 and hyper:

DD_LOG_LEVEL_BY_TARGET entry Result
h2=debug Ignored, with a warning
hyper::proto=debug Ignored, because it is a module of hyper
h=debug Ignored, because it would also match h2 and hyper
dogstatsd=debug Used

The third row matters because an entry matches every target that starts with its text.

In the code, the function that builds the log filter, build_env_filter, takes the list of locked targets as a third argument. Its only caller is #1413. After this PR merges, #1413 will pass the four libraries and bump the serverless-components revision.

Testing

A new unit test checks the four entries in the table. The test on a Lambda function will be in #1413.

🤖 Generated with Claude Code

@lym953
lym953 marked this pull request as ready for review October 14, 2026 19:47
@lym953
lym953 requested review from a team as code owners October 14, 2026 19:47
@lym953
lym953 requested review from duncanpharvey and shreyamalpani and a balanced review from Copilot and removed request for a team October 14, 2026 19:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The prefix checks implement the documented locking behavior, with focused tests and no identified blocking issues.

0 open findings

What changed in this PR

Adds agent-controlled target locks to prevent DD_LOG_LEVEL_BY_TARGET from overriding protected logging levels.

Changes:

  • Adds a locked_targets argument and rejects overlapping target prefixes.
  • Tests exact, descendant, and ancestor matches while allowing unrelated targets.
  • Documents locking behavior and updates usage examples.
File Description
crates/​datadog-serverless-logging/​src/​lib.rs Implements target locking and updates unit tests.
crates/​datadog-serverless-logging/​README.md Documents locked targets and the updated API.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

build_env_filter takes a list of targets whose level no entry can change.
An entry is not valid if its target starts with a locked target, or if a
locked target starts with its target, because an entry also matches every
target that starts with its text. The Lambda extension will lock h2,
hyper, reqwest and rustls: it sends its own logs to Datadog, so the logs
these libraries write for each request would add lines to each flush.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lym953
lym953 force-pushed the yiming.luo/serverless-logging-locked-targets branch from 160f642 to d3ffd98 Compare October 15, 2026 18:17

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants